How is `toString` in `scala.Enumeration$Value` implemented?

Posted by Red Hyena on Stack Overflow See other posts from Stack Overflow or by Red Hyena
Published on 2010-05-27T05:58:57Z Indexed on 2010/05/27 6:01 UTC
Read the original article Hit count: 173

Filed under:
|

I have an enum Fruit defined as:

object Fruit extends Enumeration {
  val Apple, Banana, Cherry = Value
}

Now printing values of this enum, on Scala 2.7.x gives:

scala> Fruit foreach println
line1$object$$iw$$iw$Fruit(0)
line1$object$$iw$$iw$Fruit(1)
line1$object$$iw$$iw$Fruit(2)

However the same operation on Scala 2.8 gives:

scala> Fruit foreach println       
warning: there were deprecation warnings; re-run with -deprecation for details
Apple
Banana
Cherry

My question is:

How is the method toString in Enumeration in Scala 2.8 is implemented? I tried looking into the source of Enumeration but couldn't understand anything.

© Stack Overflow or respective owner

Related posts about scala

Related posts about enumeration